using UnityEngine;

public class ProfileCounters : MonoBehaviour
{
	[HideInInspector]
	public static ProfileCounters instance;

	public PakageSettingsListsHolder pakageSettingsListsHolder;

	public int reputationPoints;

	public int currentReputationLevel;

	public int coinsCount;

	public int coinsCollected;

	public int PVPKills;

	public int PVPWins;

	public int SendboxKills;

	public int SendboxWins;

	public int destroyedOnlineCars;

	public int destroyedOnlineTanks;

	public int destroyedOnlineHelicopters;

	public int destroyedOnlineBoats;

	public int destroyedOnlineBikes;

	public int destroyedOfflineCars;

	public int destroyedOfflineTanks;

	public int destroyedOfflineHelicopters;

	public int destroyedOfflineBoats;

	public int destroyedOfflineBikes;

	public int killdOfflineCops;

	public int killdOfflineCitizens;

	public int killdOfflineBandits;

	public int killdOfflineZombies;

	public double totalTimePlayed;

	public int allEarnedCash;

	public int allSpentCash;

	public int allMissions;

	public int comletedMissions;

	private void Awake()
	{
		instance = this;
	}

	private void Start()
	{
		UpdateAllCounters();
	}

	public void UpdateCashCounters()
	{
		allSpentCash = BCWStorage.Get<int>(settings.keyAllSpentCash);
		allEarnedCash = BCWStorage.Get<int>(settings.keyAllEarnedCash);
		if (allEarnedCash == 0)
		{
			allEarnedCash = settings.CathedExeptions;
			BCWStorage.Set(settings.keyAllSpentCash, allEarnedCash);
		}
	}

	public void UpdateMissionCounters()
	{
		comletedMissions = 0;
		if (!(ManagerMissions.instance != null))
		{
			return;
		}
		foreach (MissionBase item in ManagerMissions.instance.listMission)
		{
			if (item.MissionIsComplete())
			{
				comletedMissions++;
			}
		}
	}

	public void UpdateAllCounters()
	{
		UpdateCashCounters();
		UpdateMissionCounters();
		pakageSettingsListsHolder.RefreshAllCoins();
		coinsCount = pakageSettingsListsHolder.allCoinsCount;
		coinsCollected = pakageSettingsListsHolder.allCoinsCollected;
		reputationPoints = BCWStorage.Get<int>(settings.keyReputationPoints);
		currentReputationLevel = BCWStorage.Get<int>(settings.keyCurrentReputationLevel);
		PVPKills = BCWStorage.Get<int>(settings.keyPVPKills);
		PVPWins = BCWStorage.Get<int>(settings.keyPVPWins);
		SendboxKills = BCWStorage.Get<int>(settings.keySandboxKills);
		SendboxWins = BCWStorage.Get<int>(settings.keySandboxWins);
		destroyedOnlineCars = BCWStorage.Get<int>(settings.keyDestroyedOnlineCars);
		destroyedOnlineTanks = BCWStorage.Get<int>(settings.keyDestroyedOnlineTanks);
		destroyedOnlineHelicopters = BCWStorage.Get<int>(settings.keyDestroyedOnlineHelicopters);
		destroyedOnlineBoats = BCWStorage.Get<int>(settings.keyDestroyedOnlineBoats);
		destroyedOnlineBikes = BCWStorage.Get<int>(settings.keyDestroyedOnlineBikes);
		destroyedOfflineCars = BCWStorage.Get<int>(settings.keyDestroyedOfflineCars);
		destroyedOfflineTanks = BCWStorage.Get<int>(settings.keyDestroyedOfflineTanks);
		destroyedOfflineHelicopters = BCWStorage.Get<int>(settings.keyDestroyedOfflineHelicopters);
		destroyedOfflineBoats = BCWStorage.Get<int>(settings.keyDestroyedOfflineBoats);
		destroyedOfflineBikes = BCWStorage.Get<int>(settings.keyDestroyedOfflineBikes);
		killdOfflineCops = BCWStorage.Get<int>(settings.keyKilldOfflineCops);
		killdOfflineCitizens = BCWStorage.Get<int>(settings.keyKilldOfflineCitizens);
		killdOfflineBandits = BCWStorage.Get<int>(settings.keyKilldOfflineBandits);
		killdOfflineZombies = BCWStorage.Get<int>(settings.keyKilldOfflineZombies);
		double.TryParse(BCWStorage.Get<string>(settings.keyTotalTimePlayed), out totalTimePlayed);
	}
}
